package com.zxm.sunshineaiary.adapter;

import com.zxm.sunshineaiary.info.WeatherInfo;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class WeatherAdapter extends BaseAdapter {

	private Context mContext = null;

	public WeatherAdapter(Context c) {
		mContext = c;
	}

	public int getCount() {
		return WeatherInfo.getWeatherCount();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView == null) {
			imageView = new ImageView(mContext);
			imageView.setLayoutParams(new GridView.LayoutParams(120, 120));// 设置ImageView宽高
//			imageView.setAdjustViewBounds(false);
//			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			imageView.setPadding(8, 8, 8, 8);
		} else {
			imageView = (ImageView) convertView;
		}

		imageView.setImageResource(WeatherInfo.getWeatherId(position));

		return imageView;
	}
}
